<template>
  <div>
    <!--使用headerzujian-->
    <home-header></home-header>
    <home-swiper :swiperList="swiper"></home-swiper>
    <home-icons :iconList="icon"></home-icons>
    <home-other :otherList="other" :yLike="otherLike"></home-other>
    <home-week :weekList="week"></home-week>
  </div>
</template>

<script>
// 使用header组件
import HomeHeader from './components/Header.vue'
// 使用Sweiper组件
import HomeSwiper from './components/Swiper.vue'
import HomeIcons from './components/Icon.vue'
import HomeOther from './components/Other.vue'
import HomeWeek from './components/Week.vue'
// 引入axios
import axios from 'axios'
export default {
  name: 'Home',
  components: {// 使用组件
    HomeHeader,
    HomeSwiper,
    HomeIcons,
    HomeOther,
    HomeWeek
  },
  data () {
    return {
      swiper: [], // swiper数据
      icon: [],
      other: [],
      otherLike: [],
      week: []
    }
  },
  methods: {
    getHomeInfo () {
      axios.get('static/index.json').then(this.getSucc)
    },
    getSucc (res) {
      res = res.data
      if (res.ret && res.data) {
        const data = res.data
        this.swiper = data.Imgsrc // 请求的swiper数据
        this.icon = data.iconList
        this.other = data.otherList
        this.otherLike = data.yLikeList
        this.week = data.WeekList
      }
      console.log(res)
    }
  },
  mounted () { // (钩子函数)  主要用来向后台请求拿到数据后做一些业务处理,
    this.getHomeInfo()
  }
}
</script>

<style  scoped>

</style>
